import usr.screen as Screen
from usr.theme import Theme

class Window:
    def __init__(self):
        self.canvas = Screen.canvas
        self.visible = False
        self.on_create()
    
    def show(self):
        self.visible = True
        self.update()

    def close(self):
        self.visible = False
        self.on_close()

    def update(self):
        self.on_draw()

    def on_draw(self):
        pass

    def on_create(self):
        pass

    def on_show(self):
        pass

    def on_close(self):
        pass
    
    def draw_background(self):
         self.canvas.clear(Theme.THEME_BACKGROUND)

    def draw_statusbar(self):
        self.canvas.fill_rect(0, 0, 239, 28, Theme.THEME_STATUSBAR_BG)

    def draw_frame(self):
        self.canvas.draw_rect(0, 0, 239, 239, Theme.THEME_BORDER)

    def draw_text(self, x1, y1, x2, y2, text, fc, bc):
        return self.canvas.draw_rect_text(x1, y1, x2, y2, text, fc, bc)
